const chalk = require("chalk");
const compressing = require("compressing");
const fs = require("fs");

// 要压缩的目录
const targetDir = 'public/txt';
const zipStream = new compressing.zip.Stream();
const destStream = fs.createWriteStream('dist/limeng.zip');

const files = fs.readdirSync(targetDir);

files.forEach(i => {
    zipStream.addEntry(`${targetDir}/${i}`);
})

const pipe = require('multipipe');
pipe(zipStream, destStream, (err) => {
    if (err) console.log(err);
    if (!err) console.log(chalk.yellow("压缩成功"));
})
